package com.superiron.scaffold.task;

import com.superiron.scaffold.security.component.DynamicSecurityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.util.concurrent.ExecutionException;

@Slf4j
@Service
public class UpdateMenuScheduledService {
	
	@Autowired
	private DynamicSecurityService dynamicSecurityService;
	
	/**
	 * 处理设备实时消息日志
	 *
	 * @throws ExecutionException
	 * @throws InterruptedException
	 */
	@Scheduled(cron = "0 0 */6 * * ?")
	public void apiUpload() throws ExecutionException, InterruptedException {
		long now = System.currentTimeMillis();
		log.info("更新菜单权限 start：{}", now);
		
		dynamicSecurityService.loadDataSource();
		
		log.info("更新菜单权限 end：{}", System.currentTimeMillis() - now);
	}
}
